package sz.szsmk.citizencard.ui.adapter;

import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.layout.DefaultLayoutHelper;
import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.databinding.HomeCardViewBinding;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/6/9 17:26
 * description:首页市民卡层
 */
public class UserCardAdapter extends DelegateAdapter.Adapter<UserCardAdapter.UserCardViewHolder> {

    private Context mContext;
    private LayoutHelper mDefaultLayoutHelper;

    public UserCardAdapter(Context context, DefaultLayoutHelper userCardHelper) {
        mContext = context;
        mDefaultLayoutHelper = userCardHelper;
    }

    @Override
    public LayoutHelper onCreateLayoutHelper() {
        return mDefaultLayoutHelper;
    }

    @Override
    public int getItemViewType(int position) {
        return R.layout.home_card_view;
    }

    @Override
    public int getItemCount() {
        return 1;
    }

    @Override
    public UserCardViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return UserCardViewHolder.creat(parent);
    }

    @Override
    public void onBindViewHolder(UserCardViewHolder holder, int position) {
        loadItemData(position, holder.binding);
    }

    private void loadItemData(int position, HomeCardViewBinding binding) {

    }


    static class UserCardViewHolder extends RecyclerView.ViewHolder {
        public HomeCardViewBinding binding;

        public static UserCardViewHolder creat(ViewGroup parent) {
            HomeCardViewBinding binding = HomeCardViewBinding
                    .inflate(LayoutInflater.from((parent.getContext())), parent, false);
            return new UserCardViewHolder(binding);
        }


        public UserCardViewHolder(HomeCardViewBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }
    }
}
